<?php
function save_report($reporttitle,$content,$reportdate,$userid){
	$query="INSERT INTO report(REPORTTITLE,CONTENT,REPORTDATE,USERID) VALUES('$reporttitle','$content','$reportdate',$userid)";
	mysql_query($query);
	$query="SELECT Id FROM report WHERE USERID=$userid AND CONTENT='$content' ORDER BY REPORTDATE LIMIT 0,1";
	$result=mysql_query($query);
	return $result;
}
function get_report($id){
	$query="SELECT report.*,user.USERNAME FROM report,user WHERE report.Id=$id AND report.USERID=user.USERID";
	$result=mysql_query($query);
	return $result;
}
function get_report_list($userid){
	$query="SELECT report.*,user.USERNAME 
			FROM report,user WHERE report.USERID IN
			(select USERID FROM user WHERE USERGROUP = $userid) 
			AND report.USERID=user.USERID 
			ORDER BY REPORTDATE DESC LIMIT 0,20";
	$result=mysql_query($query);
	return $result;
}

function get_report_list_s($userid){
	$query="SELECT report.*
			FROM report WHERE USERID = $userid 
			ORDER BY REPORTDATE DESC LIMIT 0,20";
	$result=mysql_query($query);
	return $result;
}

function save_comment($titleid,$comment){
	$query="UPDATE report SET COMMENT='$comment' WHERE Id=$titleid";
	mysql_query($query);
}
?>